import React, { Component } from 'react'
import Child from './Child'

export default class Prop extends Component {
    state = {
        count: 888
    }
    render() {
        const { count } = this.state
        return (
            <div>
                {/* 父组件向子组件传值 (只读) */}
                {/* 1. 在子组件上自定义属性传递 */}
                {/* 2. 在子组件中通过props来接收 */}
                <h3>
                    我是父组件 --- { count }
                </h3>
                <button onClick={() => {
                    this.setState({
                        count: this.state.count += 1
                    })
                }}>+1</button>
                <Child count = { count }/>
            </div>
        )
    }
}
